package deepbrain.iit;

import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;

public class PhiCompResult {

	private static Comparator<EICompResult> comparator = new Comparator<EICompResult>() {

		public int compare(EICompResult o1, EICompResult o2) {
			if (o1.ei < o2.ei)
				return -1;
			if (o1.ei == o2.ei)
				return 0;
			return +1;
		}
	};

	public Queue<EICompResult> MIPs = new PriorityQueue<EICompResult>(8,
			comparator);

	public double PHI = Double.MAX_VALUE;
	public double MIN_NORMED_EI = 0.0;

	@Override
	public String toString() {
		if (MIPs.size() == 0)
			return "The state has no predecessor state.\n";

		StringBuilder builder = new StringBuilder(80);
		builder.append("PHI: ");
		builder.append(PHI);
		builder.append("\tMIN_NORMED_EI: ");
		builder.append(MIN_NORMED_EI);
		builder.append("\nMIPS: \n");
		for (EICompResult MIP : MIPs) {
			if (MIP.ei == PHI)
				builder.append("   *");
			else
				builder.append("    ");
			builder.append(MIP);
			builder.append("\n");
		}
		return builder.toString();
	}

}
